<div class="modal-dialog">
    <div class="modal-content">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">关闭</span></button>
            <h4 class="modal-title">分类信息</h4>
        </div>
        <div class="modal-body">
            <div class="container">
                <div class="row">
                    <form id="infoFrom" class="form-horizontal" data-toggle="validator">
                        <input type="hidden" name="id" value="${category.id!}">
                        <div class="form-group">
                            <label class="col-md-2 control-label required">父级分类：</label>
                            <div class="col-md-4">
                                <select name="parentId" value="${category.parentId!}" class="form-control">
                                    <option value="0">父级分类</option>
                                    <#list categoryList as category>
                                        <#if category.parentId?? && category.id?c == category.parentId?c>
                                            <option value="${category.id}" selected>${category.name}</option>
                                        <#else>
                                            <option value="${category.id}">${category.name}</option>
                                        </#if>
                                    </#list>
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-md-2 control-label required">分类名称：</label>
                            <div class="col-md-4">
                                <input type="text" name="name" value="${category.name!}" placeholder="请输入分类名称" class="form-control">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-md-2 control-label">分类描述：</label>
                            <div class="col-md-4">
                                <input type="text" name="description" value="${category.description!}" placeholder="请输入分类描述" class="form-control">
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
    <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
        <button type="button" class="btn btn-primary save">保存</button>
    </div>

</div>
<script>
    $('.save').on("click", function () {
        if ($("#infoFrom").valid()) {
            $.ajax({
                type: 'POST',
                url: '/admin/saveCategory',
                data: $("#infoFrom").serialize(),
                success: function (data) {
                    successTip(data, dg, dlg);
                }
            })
        }
    });
</script>